<script>
  import { invoke } from "@tauri-apps/api"
  import SystemInfo from "./SystemInfo.svelte"
  import MirrorList from "./MirrorList.svelte"

  let system = {}
  let mirrors = []

  // 加载系统信息
  async function loadSystem() {
    system = await invoke("get_system_info")
  }

  // 初始化镜像列表
  async function loadMirrors() {
    mirrors = await invoke("get_mirror_list", { distro: system.distro })
  }
</script>

<main class="p-4 max-w-4xl mx-auto">
  <SystemInfo {system} />
  
  <div class="my-6">
    <MirrorList {mirrors} on:switch={e => invoke('switch_mirror', { url: e.detail })} />
  </div>
</main>